
import 'package:baselib/utils/image_util.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/drawable_util.dart';

class WidgetManager{

  //圆形或者椭圆头像
  static buildCicleImagWidget(
      String imgPath,
      {
        Key? key,
        String? placeholder,
        double? width,
        double? height,
        BoxFit? fit,
        EdgeInsetsGeometry? margin,
        EdgeInsetsGeometry? padding,
        Color? backgroundColor,
        bool? isCircle,
        double? roundRadius,
        BoxBorder? border,
      }){
    // print('buildCicleWidget-->imgPath=$imgPath,placeholder=$placeholder');
    return
      (isCircle??true)?
      Container(
        margin:margin,
        padding: padding,
        width: width,
        height: height,
        decoration: BoxDecoration(
            color: backgroundColor,
            borderRadius: BorderRadius.all(Radius.circular(width??0)),
            border: border
        ),
        child:(!(imgPath??'').startsWith('http'))?
        ClipOval(
          child: ImageUtil.loadAssetImage(
              (imgPath??'').isEmpty?drawable_icon_logo:(imgPath??drawable_icon_logo),
              width: width,
              height: height,
              fit: fit??BoxFit.cover
          ),
        ):
        ClipOval(
          child: ImageUtil.loadNetworkImage(
              imgPath,
              placeholder: placeholder??drawable_icon_logo,
              width: width,
              height: height,
              key: key,
              fit: fit??BoxFit.cover
          ),
        ),
      ):Container(
        margin:margin,
        padding: padding,
        width: width,
        height: height,
        decoration: BoxDecoration(
            border: border,
          color: backgroundColor,
        ),
        child:(!(imgPath??'').startsWith('http'))?
        ClipRRect(
          borderRadius: BorderRadius.circular(roundRadius??5),
          child: ImageUtil.loadAssetImage(
              placeholder??drawable_icon_logo,
              width: width,
              height: height,
              fit: fit??BoxFit.cover
          ),
        ):
        ClipRRect(
          borderRadius: BorderRadius.circular(roundRadius??5),
          child: ImageUtil.loadNetworkImage(
              imgPath,
              placeholder: placeholder??drawable_icon_logo,
              width: width,
              height: height,
              key: key,
              fit: fit??BoxFit.cover
          ),
        ),
      )
    ;
  }
}